import * as Blockly from 'blockly/core';
import profile from 'profile';

//////////////////颜色/////////////////////
const CONTROL_HUE = 120;
const DIGITAL_HUE = 230;
const ANALOG_HUE = 360;
const SPECIAL_HUE = 320;
const DISPLAY_HUE = 275;
const COMMUNICATE_HUE = 180;


/////////////////模拟输出//////////////////////
export const ke_a_Write = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.Kids_anologWrite);
        //.appendField(new Blockly.FieldImage("../../media/KS0077/ks77_led3.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("num", Number)
            .appendField(Blockly.Msg.Kids_value)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);

        //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.ke_ON, "HIGH"], [Blockly.Msg.ke_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

//////////////////红色LED////////////////
export const ke_led_r = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            //.appendField(Blockly.Msg.MIXLY_ke_LED1)
            .appendField(Blockly.Msg.ke_red_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_red.png"), 52, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
//////////////////黄色LED////////////////
export const ke_led_y = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_yellow_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_yellow.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
//////////////////白色LED////////////////
export const ke_led_w = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_white_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_white.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
//////////////////绿色LED////////////////
export const ke_led_g = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_green_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_g.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
//////////////////蓝色LED////////////////
export const ke_led_b = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_blue_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_b.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

export const ke_jg = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_jg1)
            .appendField(new Blockly.FieldImage(require("../media/ke_jg.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


export const ke_dual = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_dual_led)
            .appendField(new Blockly.FieldImage(require("../media/ke_led_double.png"), 43, 32));
        this.appendValueInput("PIN1", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT2");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

export const ke_qcd = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_QCD);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

//////////////////RGB1////////////////////
export const ke_rgb1_1 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_RGB_A)
            .appendField(new Blockly.FieldImage(require("../media/ke_rgb2.png"), 43, 32));
        this.appendValueInput("PIN1", Number)
            .appendField("R:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "LOW"], [Blockly.Msg.Kids_OFF, "HIGH"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField("G:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "LOW"], [Blockly.Msg.Kids_OFF, "HIGH"]]), "STAT2");
        this.appendValueInput("PIN3", Number)
            .appendField("B:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "LOW"], [Blockly.Msg.Kids_OFF, "HIGH"]]), "STAT3");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


////////////////////////rgb01///////////////////////////////////
export const ke_rgb1_2 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_RGB_A)
            .appendField(new Blockly.FieldImage(require("../media/ke_rgb2.png"), 43, 32));
        this.appendValueInput("R", Number)
            .appendField("R")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput("r", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("R(0~255):");
        this.appendValueInput("G", Number)
            .appendField("G")
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("g", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("G(0~255):");
        this.appendValueInput("B", Number)
            .appendField("B")
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("b", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("B(0~255):");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

//////////////////RGB2///////////////////
export const ke_rgb2_1 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_RGB_B)
            .appendField(new Blockly.FieldImage(require("../media/ke_rgb2.png"), 43, 32));
        this.appendValueInput("PIN1", Number)
            .appendField("R:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField("G:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT2");
        this.appendValueInput("PIN3", Number)
            .appendField("B:")
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT3");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


////////////////////////rgb01///////////////////////////////////
export const ke_rgb2_2 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_RGB_B)
            .appendField(new Blockly.FieldImage(require("../media/ke_rgb2.png"), 43, 32));
        this.appendValueInput("R", Number)
            .appendField("R")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput("r", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("R(0~255):");
        this.appendValueInput("G", Number)
            .appendField("G")
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("g", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("G(0~255):");
        this.appendValueInput("B", Number)
            .appendField("B")
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("b", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("B(0~255):");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};


/////////////////蜂鸣器//////////////////////
export const ke_w_buzzer1 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BUZZER1)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_y.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
export const ke_w_buzzer2 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BUZZER2)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_w.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput('FREQUENCY')
            .setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_FREQUENCY);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
    }
};
export const ke_w_buzzer3 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BUZZER2)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_w.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput('FREQUENCY')
            .setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_FREQUENCY);
        this.appendValueInput('DURATION')
            .setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_DURATION);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
    }
};

//////////////////蜂鸣器//////////////////
var TONE_NOTES = [
    ["NOTE_C3", "131"], ["NOTE_D3", "147"], ["NOTE_E3", "165"], ["NOTE_F3", "175"], ["NOTE_G3", "196"], ["NOTE_A3", "220"], ["NOTE_B3", "247"],
    ["NOTE_C4", "262"], ["NOTE_D4", "294"], ["NOTE_E4", "330"], ["NOTE_F4", "349"], ["NOTE_G4", "392"], ["NOTE_A4", "440"], ["NOTE_B4", "494"],
    ["NOTE_C5", "532"], ["NOTE_D5", "587"], ["NOTE_E5", "659"], ["NOTE_F5", "698"], ["NOTE_G5", "784"], ["NOTE_A5", "880"], ["NOTE_B5", "988"]
];


export const ke_tone01 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown(TONE_NOTES), 'STAT');
        this.setOutput(true, Number);
    }
};

export const ke_buzzer = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BUZZER2)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_w.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput('FREQUENCY')
            .setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.kids_tone);

        //this.appendValueInput('DURATION')
        //.setCheck(Number)
        //.setAlign(Blockly.ALIGN_RIGHT)
        //.appendField(Blockly.Msg.kids_beat);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.kids_beat)
            .appendField(new Blockly.FieldDropdown([["1/8", "125"], ["3/8", "375"], ["1/4", "250"], ["3/4", "750"], ["1/2", "500"], ["1", "1000"]]), 'beat1');

        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
    }
};


///////////music////////////////////
export const ke_music = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.kids_play_tone)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_w.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            //.appendField(new Blockly.FieldDropdown([["Birthday", "Birthday"],["City of Sky", "City of Sky"],["Ode to Joy", "Ode to Joy"]]), 'play');
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.kids_Ode_to_joy, "Ode to Joy"], [Blockly.Msg.kids_birthday, "Birthday"]]), 'play');

        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_NOTONE);
    }
};

////////////////////关闭蜂鸣器////////////////////////
export const ke_notone = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.kids_notone)
            .appendField(new Blockly.FieldImage(require("../media/ke_buzzer_w.png"), 39, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        //this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_NOTONE);
    }
};


///////////////////////继电器////////////////////////////
export const ke_relay = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_RELAY)
            .appendField(new Blockly.FieldImage(require("../media/ke_relay.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////////震动马达////////////////////////////
export const ke_v_motor = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_v_motor)
            .appendField(new Blockly.FieldImage(require("../media/ke_v_motor.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_STAT)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////////扬声器模块////////////////////////////
export const ke_speaker = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SPEAKER)
            .appendField(new Blockly.FieldImage(require("../media/ke_speaker.png"), 57, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput('FREQUENCY', Number)
            .setCheck(Number)
            .appendField(Blockly.Msg.MIXLY_FREQUENCY);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
    }
};
// Speaker - 喇叭+持续时间
export const ke_speaker2 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SPEAKER)
            .appendField(new Blockly.FieldImage(require("../media/ke_speaker.png"), 57, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput('FREQUENCY')
            .setCheck(Number)
            .appendField(Blockly.Msg.MIXLY_FREQUENCY);
        this.appendValueInput('DURATION')
            .setCheck(Number)
            .appendField(Blockly.Msg.MIXLY_DURATION);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_DELAY_MS);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
    }
};
// Notone - 结束声音
export const ke_speaker_notone = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_NOTONE_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_NOTONE);
    }
};

////////////////////////电机///////////////////////////////////
export const ke_motor = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_MOTOR01);
        this.appendValueInput("PIN1", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INA')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INB')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT2");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

////////////////////////电机001///////////////////////////////////
export const ke_motor001 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_MOTOR01);
        this.appendValueInput("PIN1", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INA')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("pwmb")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("PWMB:");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

////////////////////////电机2///////////////////////////////////
export const ke_motor2 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_MOTOR)
            .appendField(new Blockly.FieldImage(require("../media/ke_fs.png"), 43, 32));
        this.appendValueInput("PIN1", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INA')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INB')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT2");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

////////////////////////电机002///////////////////////////////////
export const ke_motor002 = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_MOTOR)
            .appendField(new Blockly.FieldImage(require("../media/ke_fs.png"), 43, 60));
        this.appendValueInput("PIN1", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField('INA')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT1");
        this.appendValueInput("PIN2", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setAlign(Blockly.ALIGN_RIGHT)
            .setCheck(Number);
        this.appendValueInput("pwmb")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("PWMB:");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


///////////////////////////舵机///////////////////////////////////
export const ke_servo = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_ke_SERVO)
            .appendField(new Blockly.FieldImage(require("../media/ke_servo.png"), 70, 32))
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendValueInput("angle", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_DEGREE_0_180);
        this.appendValueInput("time", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_DELAY + '(' + Blockly.Msg.MIXLY_DELAY_MS + ')');
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERVO_MOVE);
    }
};

export const ke_servo_r = {
    init: function () {
        this.setColour(CONTROL_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_ke_SERVO)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_READ_DEGREES)
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERVO_READ);
    }
};

/////////////////////数字传感器///////////////////////////////

///////////人体红外传感器////////////////////
export const ke_ir_g = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_IR_G)
            .appendField(new Blockly.FieldImage(require("../media/ke_rentihongwai.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////火焰传感器////////////////////

export const ke_flame = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_FLAME)
            .appendField(new Blockly.FieldImage(require("../media/ke_fire.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////霍尔传感器////////////////////
export const ke_hall = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_HALL)
            .appendField(new Blockly.FieldImage(require("../media/ke_hall.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////敲击传感器////////////////////
export const ke_crash = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_KNOCK)
            .appendField(new Blockly.FieldImage(require("../media/ke_zhengdong.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////按键传感器////////////////////
export const ke_button = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BUTTON)
            .appendField(new Blockly.FieldImage(require("../media/ke_button.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////自锁按键传感器////////////////////
export const ke_sl_button = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_sl_BUTTON)
            .appendField(new Blockly.FieldImage(require("../media/ke_sl_button.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};
///////////电容触摸传感器////////////////////
export const ke_tuoch = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_TUOCH)
            .appendField(new Blockly.FieldImage(require("../media/ke_touch.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////碰撞传感器////////////////////
export const ke_knock = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_CRASH)
            .appendField(new Blockly.FieldImage(require("../media/ke_pengzhuang.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////倾斜传感器////////////////////
export const ke_tilt = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_TILT)
            .appendField(new Blockly.FieldImage(require("../media/ke_qingxie.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////振动传感器////////////////////
export const ke_shake = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SHAKE)
            .appendField(new Blockly.FieldImage(require("../media/ke_qiaoji.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};



///////////干簧管传感器////////////////////
export const ke_reed_s = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_REED_S)
            .appendField(new Blockly.FieldImage(require("../media/ke_ghg.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////循迹传感器////////////////////
export const ke_track = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_TRACK)
            .appendField(new Blockly.FieldImage(require("../media/ke_xunji.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////避障传感器////////////////////
export const ke_avoid = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_AVOID)
            .appendField(new Blockly.FieldImage(require("../media/ke_hongwaibz.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////光折断传感器////////////////////
export const ke_light_b = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_LIGHT_B)
            .appendField(new Blockly.FieldImage(require("../media/ke_photo.png"), 43, 32));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////烟雾数字传感器////////////////////
export const ke_smoke_D = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SMOKE)
            .appendField(new Blockly.FieldImage(require("../media/ke_gas.png"), 60, 48));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

///////////酒精数字传感器////////////////////
export const ke_alcohol_D = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_ALCOHOL)
            .appendField(new Blockly.FieldImage(require("../media/ke_alcohol.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};


///////////////////////////模拟传感器//////////////////////////
///////////模拟温度传感器///////////////
export const ke_analog_t = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_ANALOG_T)
            .appendField(new Blockly.FieldImage(require("../media/ke_mnwd.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////声音传感器///////////////
export const ke_sound = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SOUND)
            .appendField(new Blockly.FieldImage(require("../media/ke_sound.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////光线传感器///////////////
export const ke_light = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_LIGHT)
            .appendField(new Blockly.FieldImage(require("../media/ke_guangmin.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////紫外线传感器///////////////
export const ke_UV = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_UV)
            .appendField(new Blockly.FieldImage(require("../media/ke_UV.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////压电传感器///////////////
export const ke_Piezo = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_Piezo)
            .appendField(new Blockly.FieldImage(require("../media/ke_Piezo.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////电位器///////////////
export const ke_potentiometer = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_POTENTIOMETER)
            .appendField(new Blockly.FieldImage(require("../media/ke_dianweiqi.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////LM35///////////////
export const ke_lm35 = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_LM35)
            .appendField(new Blockly.FieldImage(require("../media/ke_lm35.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////滑动电位器///////////////
export const ke_slide_potentiometer = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SLIDE_POTENTIOMETER)
            .appendField(new Blockly.FieldImage(require("../media/ke_hddwq.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////TEMT6000环境光///////////////
export const ke_temt6000 = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_TEMT6000)
            .appendField(new Blockly.FieldImage(require("../media/ke_temt6000.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////水蒸气传感器///////////////
export const ke_steam = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_STEAM)
            .appendField(new Blockly.FieldImage(require("../media/ke_steam.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////薄膜压力传感器///////////////
export const ke_film_p = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_FILM_P)
            .appendField(new Blockly.FieldImage(require("../media/ke_tptouch.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////摇杆传感器///////////////
var joystick = [
    ["x", "Lx"],
    ["y", "Ly"],
    // ["z", "Lz"],
];

export const ke_joystick = {
    init: function () {
        this.setColour(ANALOG_HUE);
        //this.appendDummyInput("")
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(joystick), "joy");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_JOYSTICK)
            .appendField(new Blockly.FieldImage(require("../media/ke_joys.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////遥感按钮////////////////////
export const ke_joystick_btn = {
    init: function () {
        this.setColour(DIGITAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_JOYSTICK_btn)
            .appendField(new Blockly.FieldImage(require("../media/ke_joys.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};


///////////烟雾传感器///////////////
export const ke_smoke = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SMOKE)
            .appendField(new Blockly.FieldImage(require("../media/ke_gas.png"), 60, 48));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////酒精传感器///////////////
export const ke_alcohol = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_ALCOHOL)
            .appendField(new Blockly.FieldImage(require("../media/ke_alcohol.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};



///////////火焰模拟传感器///////////////
export const ke_fire2 = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_FLAME)
            .appendField(new Blockly.FieldImage(require("../media/ke_fire.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};


///////////电压传感器///////////////
export const ke_Voltage = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_Voltage)
            .appendField(new Blockly.FieldImage(require("../media/ke_Voltage.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};

///////////电流传感器///////////////
export const ke_Current = {
    init: function () {
        this.setColour(ANALOG_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_Current)
            .appendField(new Blockly.FieldImage(require("../media/ke_Current.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};


///////////18B20温度模块///////////////
export const ke_18b20 = {
    init: function () {
        var UNIT = [[Blockly.Msg.MIXLY_DS18B20_C, '0'], [Blockly.Msg.MIXLY_DS18B20_F, '1']];
        this.setColour(SPECIAL_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_ke_18B20)
            .appendField(new Blockly.FieldImage(require("../media/ke_18B20.png"), 50, 40))
            .appendField(Blockly.Msg.Kids_pin)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_18B20_R)
            .appendField(new Blockly.FieldDropdown(UNIT), "UNIT");
        this.setOutput(true, Number);
    }
};

///////////////////////////////DHT11//////////////////////////////////
export const ke_dht11 = {
    init: function () {
        var WHAT = [[Blockly.Msg.MIXLY_DHT11_T, 'temperature'], [Blockly.Msg.MIXLY_DHT11_H, 'humidity']];
        this.setColour(SPECIAL_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(new Blockly.FieldDropdown([['DHT11', '11'], ['DHT21', '21'], ['DHT22', '22'], ['DHT33', '33'], ['DHT44', '44']]), 'TYPE')
            .appendField(new Blockly.FieldImage(require("../media/ke_dht11.png"), 50, 40))
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown(WHAT), "WHAT");
        this.setOutput(true, Number);
        var thisBlock = this;
        this.setTooltip(function () {
            var op = thisBlock.getFieldValue('WHAT');
            var TOOLTIPS = {
                'temperature': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_TEM,
                'humidity': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_HUM
            };
            return TOOLTIPS[op];
        });
    }
};

//DHT11温湿度传感器
export const ke_DHT = {
    init: function () {
        var WHAT = [[Blockly.Msg.MIXLY_GETTEMPERATUE, 'temperature'], [Blockly.Msg.MIXLY_GETHUMIDITY, 'humidity']];
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([['DHT11', '11'], ['DHT21', '21'], ['DHT22', '22']]), 'TYPE')
            .appendField(new Blockly.FieldImage(require("../media/ke_dht11.png"), 50, 40))
            .appendField(Blockly.Msg.MIXLY_PIN)
            .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN")
            .appendField(new Blockly.FieldDropdown(WHAT), "WHAT");
        this.setOutput(true, Number);
        var thisBlock = this;
        this.setTooltip(function () {
            var op = thisBlock.getFieldValue('WHAT');
            var TOOLTIPS = {
                'temperature': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_TEM,
                'humidity': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_HUM
            };
            return TOOLTIPS[op];
        });
    }
};

//////////BMP180高度计模块///////////////
// export const ke_bmp180 = {
//     init: function () {
//         this.setColour(SPECIAL_HUE);
//         this.appendDummyInput("")
//             .appendField(Blockly.Msg.MIXLY_ke_BMP180)
//             .appendField(new Blockly.FieldImage(require("../media/ke_bmp180.png"), 50, 40));
//         this.appendValueInput("PIN", Number)
//             .appendField(Blockly.Msg.MIXLY_PIN)
//             .setCheck(Number);
//         this.setInputsInline(true);
//         this.setOutput(true, Number);
//         this.setTooltip('');
//     }
// };

/////////////////////////////////////////////
////////////////传感器////////////////////////
/////////////////////////////////////////////


///////////ADKey///////////////
export const ke_ADKey = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.kids_ADkey)
            .appendField(new Blockly.FieldImage(require("../media/ke_ADKey.png"), 60, 48));
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip('');
    }
};




///////////////超声波/////////////////////////
export const ke_sr04 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_SR04)
            .appendField(new Blockly.FieldImage(require("../media/ke_sr04.png"), 50, 40));
        this.appendValueInput("PIN1", Number)
            .appendField('Trig#')
            .setCheck(Number);
        this.appendValueInput("PIN2", Number)
            .appendField('Echo#')
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_CHAOSHENGBO);
    }
};



/////////////////////////////BMP280////////////////////////
// var BMP280_TP = [
//     [Blockly.Msg.MIXLY_ke_BMP280_T, "T"],
//     [Blockly.Msg.MIXLY_ke_BMP280_A, "P"],
//     [Blockly.Msg.MIXLY_ke_BMP180_H, "A"],
// ];
/////////////////////////////BMP280////////////////////////
// export const ke_bmp280 = {
//     init: function () {
//         this.setColour(SPECIAL_HUE);
//         this.appendDummyInput("")
//             .appendField(Blockly.Msg.MIXLY_ke_BMP280)
//             .appendField(new Blockly.FieldImage(require("../media/ke_bmp180.png"), 50, 40))
//             .appendField(Blockly.Msg.Kids_iic);
//         this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(BMP280_TP), "BMP280_PIN");
//         this.setInputsInline(true);
//         this.setOutput(true);
//     }
// };

//BME280读取
export const ke_BMP280_READ = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_SERIAL_READ)
            .appendField(new Blockly.FieldDropdown([["BMP280", "bmp"], ["BME280", "bme"]]), "TYPE")
            .appendField(new Blockly.FieldImage(require("../media/ke_bmp280.png"), 50, 40));
        this.appendValueInput("address")
            .appendField(Blockly.Msg.MIXLY_LCD_ADDRESS);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_GET)
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.blynk_IOT_IR_TEMP, "readTemperature()"], [Blockly.Msg.MIXLY_Humidity, "readHumidity()"], [Blockly.Msg.MIXLY_Altitude, "readPressure()"], [Blockly.Msg.MIXLY_HEIGHT, "readAltitude(SEALEVELPRESSURE_HPA)"]]), "BME_TYPE")
        this.setOutput(true, null);
        this.setTooltip("");
        this.setHelpUrl("");
    }
};

//ADXL345传感器-重力感应块-获取数据
var ADXL345_ZHOU = [
    [Blockly.Msg.MIXLY_ADXL345_X, "x"],
    [Blockly.Msg.MIXLY_ADXL345_Y, "y"],
    [Blockly.Msg.MIXLY_ADXL345_Z, "z"],
    [Blockly.Msg.MIXLY_ADXL345_XA, "xa"],
    [Blockly.Msg.MIXLY_ADXL345_YA, "ya"]
    //, [Blockly.Msg.MIXLY_ADXL345_ZA, "za"]
];
//传感器-重力感应块-获取数据
export const ke_adxl345 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_Ke_ADXL345)
            .appendField(new Blockly.FieldImage(require("../media/ke_345.png"), 50, 40));
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(ADXL345_ZHOU), "ADXL345_PIN");
        this.setInputsInline(true);
        this.setOutput(true);
    }
};


//传感器-MPU6050-获取数据
export const ke_MPU6050 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_MPU6050)
            .appendField(new Blockly.FieldImage(require("../media/ke_mpu6050.png"), 50, 40));
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_Accel_X, "normAccel.XAxis"],
                [Blockly.Msg.MIXLY_Accel_Y, "normAccel.YAxis"],
                [Blockly.Msg.MIXLY_Accel_Z, "normAccel.ZAxis"],
                [Blockly.Msg.MIXLY_Gyro_X, "normGyro.XAxis"],
                [Blockly.Msg.MIXLY_Gyro_Y, "normGyro.YAxis"],
                [Blockly.Msg.MIXLY_Gyro_Z, "normGyro.ZAxis"],
                [Blockly.Msg.MIXLY_readTempC, "mpu.readTemperature()"]
            ]), "MPU6050_TYPE");
        this.setInputsInline(true);
        this.setOutput(true);
    }
};

//传感器-MPU6050-更新数据
export const ke_MPU6050_update = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(require("../media/ke_mpu6050.png"), 50, 40))
            .appendField(Blockly.Msg.MIXLY_MPU6050 + Blockly.Msg.MIXLY_update_data);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};


/////////////////////////////BMP180////////////////////////
var BMP180_TP = [
    [Blockly.Msg.MIXLY_ke_BMP180_T, "T"],
    [Blockly.Msg.MIXLY_ke_BMP180_A, "P"],
    [Blockly.Msg.MIXLY_ke_BMP180_H, "A"],
];
/////////////////////////////BMP180////////////////////////
export const ke_bmp180 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_BMP180)
            .appendField(Blockly.Msg.Kids_iic);
        //.appendField(new Blockly.FieldImage(require("../media/ke_bmp180.png"), 50, 40));
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(BMP180_TP), "BMP180_PIN");
        this.setInputsInline(true);
        this.setOutput(true);
    }
};

/********************************************
TIME - 时钟模块
  - DS3231
  - DS1307
*********************************************/
// DS3231 real time clock  -- 设置时间
export const ke_ds3231_SetTime = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS3231)
            .appendField(new Blockly.FieldImage(require("../media/ke_ds3231.png"), 44, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME);
        this.appendValueInput("year")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_YEAR);
        this.appendValueInput("month")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_MONTH);
        this.appendValueInput("day")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_DAY);
        this.appendValueInput("hour")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_HOUR);
        this.appendValueInput("minute")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_MINUTE);
        this.appendValueInput("second")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_SECOND);
        this.setOutput(false, Number);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

// DS3231 real time clock  -- 设置当前时间
export const ke_ds3231_SetTime2 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS3231)
            .appendField(new Blockly.FieldImage(require("../media/ke_ds3231.png"), 44, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME)
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME2);
        this.setOutput(false, Number);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

// DS3231 real time clock  -- 获取时间
export const ke_ds3231_GetTime = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS3231)
            .appendField(new Blockly.FieldImage(require("../media/ke_ds3231.png"), 44, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_GET_TIME)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_ke_YEAR, "Year"],
                [Blockly.Msg.MIXLY_ke_MONTH, "Month"], [Blockly.Msg.MIXLY_ke_DAY, "Day"],
                [Blockly.Msg.MIXLY_ke_HOUR, "Hour"], [Blockly.Msg.MIXLY_ke_MINUTE, "Minute"],
                [Blockly.Msg.MIXLY_ke_SECOND, "Second"], [Blockly.Msg.MIXLY_ke_DAYOFWEEK, "DayOfWeek"]
            ]), "TIME_TYPE");
        this.setOutput(true, Number);
        this.setInputsInline(true);
    }
};


// DS1307 real time clock  -- 设置时间
export const ke_ds1307_SetTime = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS1307)
            .appendField(new Blockly.FieldImage(require("../media/ke_1307.png"), 32, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME);
        this.appendValueInput("year")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_YEAR);
        this.appendValueInput("month")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_MONTH);
        this.appendValueInput("day")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_DAY);
        this.appendValueInput("hour")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_HOUR);
        this.appendValueInput("minute")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_MINUTE);
        this.appendValueInput("second")
            .setCheck(Number).setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_SECOND);
        this.setOutput(false, Number);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

// DS1307 real time clock  -- 设置当前时间
export const ke_ds1307_SetTime2 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS1307)
            .appendField(new Blockly.FieldImage(require("../media/ke_1307.png"), 32, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME)
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_SET_TIME2);
        this.setOutput(false, Number);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

// DS1307 real time clock  -- 获取时间
export const ke_ds1307_GetTime = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_DS1307)
            .appendField(new Blockly.FieldImage(require("../media/ke_1307.png"), 32, 32))
            .appendField(Blockly.Msg.MIXLY_ke_DS3231_GET_TIME)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_ke_YEAR, "Year"],
                [Blockly.Msg.MIXLY_ke_MONTH, "Month"], [Blockly.Msg.MIXLY_ke_DAY, "Day"],
                [Blockly.Msg.MIXLY_ke_HOUR, "Hour"], [Blockly.Msg.MIXLY_ke_MINUTE, "Minute"],
                [Blockly.Msg.MIXLY_ke_SECOND, "Second"], [Blockly.Msg.MIXLY_ke_DAYOFWEEK, "DayOfWeek"]
            ]), "TIME_TYPE");
        this.setOutput(true, Number);
        this.setInputsInline(true);
    }
};

///////////旋转编码器////////////////////
export const ke_rotation_button = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_ROT)
            .appendField(new Blockly.FieldImage(require("../media/ke_rotaration.png"), 43, 32));
        this.appendValueInput("button", Number)
            .appendField(Blockly.Msg.Kids_rot)
            .setCheck(Number);

        this.setOutput(true, Boolean);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};


/*var rot = [
  ["right", "R"],
  ["left", "L"],
  ["button", "B"],
];*/

///////////旋转编码器////////////////////
export const ke_rotation_right = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_ROT)
            .appendField(new Blockly.FieldImage(require("../media/ke_rotaration.png"), 43, 32));
        // this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(rot), "rot");
        this.appendDummyInput()
            .appendField(Blockly.Msg.Kids_rot_count)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(new Blockly.FieldTextInput('i'), 'VAR');
        this.appendValueInput("DAT", Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("DAT")
            .setCheck(Number);
        this.appendValueInput("CLK", Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("CLK")
            .setCheck(Number);
        //this.appendValueInput("button", Number)
        // .appendField("SW")
        //  .setCheck(Number);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(false);
        this.setTooltip('');
        var thisBlock = this;
        this.setTooltip(function () {
            return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace('%1',
                thisBlock.getFieldValue('VAR'));
        });
    },
    getVars: function () {
        return [this.getFieldValue('VAR')];
    },
    renameVar: function (oldName, newName) {
        if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
            this.setTitleValue(newName, 'VAR');
        }
    }
};

/////////////////pca9685////////////////////////////
export const ke_pca9685 = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField("pca9685");
        this.appendValueInput("pin")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("pin0~15");
        this.appendValueInput("pwm")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_angle);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};

///////////////////////////红外测温传感器/////////////////

//初始化MLX90614红外测温传感器
export const mlx90614_init = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendValueInput("mlx90614_address")
            .setCheck(null)
            .appendField(Blockly.Msg.MIXLY_SETUP + " MLX90614" + Blockly.Msg.MLX90614_TYPE)
            .appendField(new Blockly.FieldImage(require("../media/ke_90614.png"), 50, 40))
            .appendField(Blockly.Msg.MIXLY_LCD_ADDRESS);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("");
    }
};


//MLX90614获取数据
export const mlx90614_get_data = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        var type = [
            [Blockly.Msg.MLX90614_TARGET_OBJECT_TEMP + "(℃)", "readObjectTempC"],
            [Blockly.Msg.MLX90614_TARGET_OBJECT_TEMP + "(℉)", "readObjectTempF"],
            [Blockly.Msg.MLX90614_AMBIENT_TEMP + "(℃)", "readAmbientTempC"],
            [Blockly.Msg.MLX90614_AMBIENT_TEMP + "(℉)", "readAmbientTempF"]];
        this.appendDummyInput()
            .appendField("MLX90614" + Blockly.Msg.MLX90614_TYPE)
            .appendField(new Blockly.FieldImage(require("../media/ke_90614.png"), 50, 40))
            .appendField(Blockly.Msg.MIXLY_GET)
            .appendField(new Blockly.FieldDropdown(type), "mlx90614_data");
        this.setInputsInline(true);
        this.setOutput(true, null);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_MLX90614_GET_DATA);
    }
};
///////////////////////////颜色传感器/////////////////
//传感器-颜色识别-获取数据
var DF_TCS34725_COLOR = [
    [Blockly.Msg.COLOUR_RGB_RED, "tcs34725.getRedToGamma()"],
    [Blockly.Msg.COLOUR_RGB_GREEN, "tcs34725.getGreenToGamma()"],
    [Blockly.Msg.COLOUR_RGB_BLUE, "tcs34725.getBlueToGamma()"],
];

// export const TCS34725_Get_RGB = {
//     init: function () {
//         this.setColour(SPECIAL_HUE);
//         this.appendDummyInput("")
//             .appendField(new Blockly.FieldImage(require("../media/ke_34725.png"), 50, 40))
//             .appendField(Blockly.Msg.TCS34725_Get_RGB)
//             .appendField(new Blockly.FieldDropdown(DF_TCS34725_COLOR), "DF_TCS34725_COLOR");
//         this.setInputsInline(true);
//         this.setOutput(true);
//     }
// };

export const TCS34725_Get_RGB = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(require("../media/ke_34725.png"), 50, 40))
            .appendField(Blockly.Msg.TCS34725_Get_RGB)
            .appendField(new Blockly.FieldDropdown(DF_TCS34725_COLOR), "DF_TCS34725_COLOR");
        this.setInputsInline(true);
        this.setOutput(true);
    }
};

///////////////////////////MAX3010X心率传感器/////////////////
var ke_MAX30102_TYPE = [
    ["温度(℃)", "particleSensor.readTemperature()"],
    ["温度(℉))", "particleSensor.readTemperatureF()"],
    ["红光", "particleSensor.getRed()"],
    ["红外光", "particleSensor.getIR()"],
    ["绿光", "particleSensor.getGreen()"],
];

export const ke_MAX3010X_Value = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(require("../media/ke_34725.png"), 50, 40))
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(new Blockly.FieldDropdown(ke_MAX30102_TYPE), "MAX3010X_TYPE");
        this.setInputsInline(true);
        this.setOutput(true);
        this.setTooltip();
    }
};

export const ke_MAX3010X_HR = {
    init: function () {
        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(require("../media/ke_34725.png"), 50, 40))
            .appendField(new Blockly.FieldTextInput('Bmp_value'), 'VAR')
        this.appendStatementInput('DO');
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
        // this.setTooltip(Blockly.Msg.MIXLY_IR_RECIEVE_TOOLTIP);
    },
    getVars: function () {
        return [this.getFieldValue('VAR')];
    },
    renameVar: function (oldName, newName) {
        if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
            this.setTitleValue(newName, 'VAR');
        }
    }
};

///////////////////////////手势识别传感器/////////////////
//传感器-手势识别-获取数据
export const ke_Gesture_APDS = {
    init: function () {
        var ke_APDS_PIN1 = [
            ["A4", "A4"]
        ];

        var ke_APDS_PIN2 = [
            ["A5", "A5"]
        ];

        this.setColour(SPECIAL_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_Gesture_APDS)
            .appendField(new Blockly.FieldImage(require("../media/ke_Gesture_APDS.png"), 32, 32)); //图片
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("SDA#")
            .appendField(new Blockly.FieldDropdown(ke_APDS_PIN1), "APDS_PIN1");
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("SCL#")
            .appendField(new Blockly.FieldDropdown(ke_APDS_PIN2), "APDS_PIN2");
        this.setInputsInline(true);
        this.setOutput(true);
    }
};

////////////////////////显示屏///////////////////////
////////////////////////////////////////////////////

//////////////////RGB灯////////////////////////////
export const ke_rgb2812 = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_2812RGB)
            .appendField(new Blockly.FieldImage(require("../media/ke_rgb2812.png"), 50, 40));
        this.appendValueInput("PIN", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_PIN);
        this.appendValueInput("num01")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_Count);
        this.appendValueInput("red")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("R：");
        this.appendValueInput("green")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("G：");
        this.appendValueInput("blue")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("B：");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};


//TM1650 4 digital display  -- 初始化
export const ke_4digitdisplay_init = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32))
            .appendField(Blockly.Msg.MIXLY_SETUP)
        this.appendValueInput("PIN1")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            // .appendField(Blockly.YF_TM1637_INIT)
            .appendField("CLK")
            .appendField(Blockly.Msg.MIXLY_PIN);
        this.appendValueInput("PIN2")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("DIO")
            .appendField(Blockly.Msg.MIXLY_PIN);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

// TM1650 4 digital display  -- 开关 清屏
export const ke_4digitdisplay_power = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32))
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_LCD_STAT_ON, "displayOn"],
                [Blockly.Msg.MIXLY_LCD_STAT_OFF, "displayOff"],
                [Blockly.Msg.MIXLY_LCD_STAT_CLEAR, "clear"]
            ]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
// TM1650 4 digital display  -- 显示字符串
export const ke_4digitdisplay_displayString = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32))
        this.appendValueInput("VALUE", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_YF_4DIGITDISPLAY_DISPLAYSTRING);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};
// TM1650 4 digital display  -- 显示数字
export const ke_4digitdisplay_displayNumber = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32));
        this.appendValueInput("VALUE")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_YF_4DIGITDISPLAY_DISPLAYNUMBER);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("支持类型：int、float、double");
    }
};
// TM1650 4 digital display  -- 小数点显示
export const ke_4digitdisplay_showDot = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32));
        this.appendValueInput('DOTNUM')
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_NOMBER1);
        //.appendField(new Blockly.FieldDropdown([["1", "0"], ["2", "1"], ["3", "2"], ["4", "3"]]), "NO")
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_NOMBER2)
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_DOT)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_4DIGITDISPLAY_ON, "true"],
                [Blockly.Msg.MIXLY_4DIGITDISPLAY_OFF, "false"]
            ]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("数字模式小数点：1~4");
    }
};

// TM1650 4 digital display  -- 设置亮度
export const ke_4digitdisplay_Brightness = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "")
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 84, 32));
        this.appendValueInput('brightness')
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_BRIGHTNESS);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_BRIGHTNESS_RANGE);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
        this.setTooltip("亮度等级范围：1~8");
    }
};

// TM1650 4 digital display  -- 时钟模式
export const ke_4digitdisplay_Time = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY + "");
        this.appendValueInput('time_hour')
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_TIME_HOUR);
        this.appendValueInput('time_minute')
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_TIME_MINUTE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_ke_4DIGITDISPLAY_TIME_SECOND)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_ke_TIME_SEC_ON, "displaySEC_ON"],
                [Blockly.Msg.MIXLY_ke_TIME_SEC_BLINK, "displaySEC_BLINK"],
                [Blockly.Msg.MIXLY_ke_TIME_SEC_OFF, "displaySEC_OFF"]
            ]), "STAT");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

/*
export const ke_display_TM1637_init = {
    init: function () {
      this.setColour(DISPLAY_HUE);
      this.appendDummyInput("")
      .appendField(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_INIT)
      .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40))
      .appendField('CLK')
      .appendField(Blockly.Msg.MIXLY_PIN)
      .appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK")
      .appendField('DIO')
      .appendField(Blockly.Msg.MIXLY_PIN)
      .appendField(new Blockly.FieldDropdown(profile.default.digital), "DIO");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setInputsInline(true);
      this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_TIP);
      this.setHelpUrl('');
//    this.setFieldValue("2", "CLK");
 //   this.setFieldValue("4", "DIO");
}
};

export const ke_display_TM1637_displyPrint = {
  init: function () {
    this.setColour(DISPLAY_HUE);
    this.appendValueInput("VALUE")
    .setAlign(Blockly.ALIGN_RIGHT)
    .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40))
    .appendField(Blockly.Msg.MIXLY_4DIGITDISPLAY + " TM1637"+Blockly.Msg.OLEDDISPLAY);
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_DISPLAYSTRING_TIP);
  }
};
var display_Time_Point = [
[Blockly.Msg.MIXLY_4DIGITDISPLAY_ON, "true"],
[Blockly.Msg.MIXLY_4DIGITDISPLAY_OFF, "false"]
];

export const ke_display_TM1637_displayTime = {
  init: function () {
    this.setColour(DISPLAY_HUE);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40))
    .appendField(Blockly.Msg.MIXLY_4DIGITDISPLAY + " TM1637"+Blockly.Msg.MIXLY_SHOW_FACE_TIME);
    this.appendValueInput("hour")
    .setCheck(Number)
    .setAlign(Blockly.ALIGN_RIGHT);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.MIXLY_HOUR);
    this.appendValueInput("minute")
    .setCheck(Number)
    .setAlign(Blockly.ALIGN_RIGHT);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.MIXLY_MINUTE);
     //  .appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_ON, "displayOn"], [Blockly.Msg.MIXLY_OFF, "displayOff"], [Blockly.Msg.MIXLY_LCD_STAT_CLEAR, "clear"]]), "STAT");
    this.appendDummyInput("").appendField(Blockly.Msg.MIXLY_DISPLAY_TM1637_Time_Point).appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_ON, "true"], [Blockly.Msg.MIXLY_OFF, "false"]]), "STAT");


    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_DISPLAYTIME_TOOLTIP);
  }
};

export const ke_display_TM1637_Brightness = {
  init: function () {
    this.setColour(DISPLAY_HUE);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40))
    .appendField(Blockly.Msg.MIXLY_4DIGITDISPLAY + " TM1637"+Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_SET_BRIGHTNESS);

    this.appendValueInput("Brightness")
    .setCheck(Number)
    .setAlign(Blockly.ALIGN_RIGHT);
    this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_4DIGITDISPLAY_BRIGHTNESS_TOOLTIP);
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setInputsInline(true);
    this.setTooltip(Blockly.Msg.MIXLY_TOOPTIP_4DIGITDISPLAY_TM1637_BRIGHTNESS);
  }
};

export const ke_display_TM1637_clearDisplay = {
  init: function () {
    this.setColour(DISPLAY_HUE);
     this.appendDummyInput()
     .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40))
    .appendField(Blockly.Msg.MIXLY_4DIGITDISPLAY + " TM1637")

    .appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LCD_STAT_CLEAR, "clear"],[Blockly.Msg.MIXLY_LCD_STAT_BLINK, "blink"],[Blockly.Msg.MIXLY_ON, "on"], [Blockly.Msg.MIXLY_OFF, "off"], ]), "STAT");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_CLEARDISPLAY);
  }
};

/////////////////////TM1637数码管初始化//放弃//////////////////////////////////
export const ke_tm1637_init = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));
        this.appendValueInput("PIN1", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("#CLK:");
        this.appendValueInput("PIN2", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("#DIO:");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        //this.setTooltip(Blockly.Msg.MIXLY_4DIGITDISPLAY_TM1637_TIP);
        //this.setHelpUrl('');
    }
};

//////////////////TM1637数码自定义显示////////////////////////////
export const ke_tm1637_dy = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));

        this.appendValueInput("num")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_value);

        this.appendValueInput("weishu")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_ws);
        this.appendValueInput("wei")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_begin);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};

//////////////////TM1637数码自定义显示是否填充////////////////////////////
export const ke_tm1637_tc = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));

        this.appendValueInput("num")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_value);

        this.appendValueInput('0and1')
            .setCheck([Number,Boolean])
            .appendField(Blockly.Msg.ke_fill0);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};

//////////////////TM1637数码管亮度////////////////////////////
export const ke_tm1637_ld = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));

        this.appendValueInput("num")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_light);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};

//////////////////TM1637数码管是否隐藏////////////////////////////
export const ke_tm1637_yc = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));

        this.appendValueInput('BOOL')
            .setCheck([Number,Boolean])
            .appendField(Blockly.Msg.ke_XY);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};

//////////////////TM1637数码管是否显示冒号////////////////////////////
export const ke_tm1637_mh = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_TM1637)
            .appendField(new Blockly.FieldImage(require("../media/ke_shumaguan.png"), 50, 40));
        this.appendValueInput("num1")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_L);
        this.appendValueInput('BOOL')
            .setCheck([Number,Boolean])
            .appendField(Blockly.Msg.ke_MH);
        this.appendValueInput("num2")
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_R);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
*/
/////////////////////8*8点阵/////////////////////

export const ke_matrix_init = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_INIT).appendField(new Blockly.FieldImage(require("../media/ke_matrix.png"), 70, 32));
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName');
        this.appendValueInput("address", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("address:");
        this.appendValueInput("PIN1").setCheck(Number).setAlign(Blockly.ALIGN_RIGHT).appendField("SDA#");
        this.appendValueInput("PIN2").setCheck(Number).setAlign(Blockly.ALIGN_RIGHT).appendField("SCL#");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        //   this.setTooltip("display_点阵屏初始化");
    }
};


//执行器_点阵屏显示_画点变量
var ke_DrawPixel_NUM = [
    [Blockly.Msg.MIXLY_4DIGITDISPLAY_ON, "1"],
    [Blockly.Msg.MIXLY_4DIGITDISPLAY_OFF, "0"]
];

//执行器_点阵屏显示_画点显示
export const ke_Matrix_POS = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName').appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOW);
        this.appendValueInput("XVALUE").setCheck(Number).setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_X);
        this.appendValueInput("YVALUE").setCheck(Number).setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_Y);
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOWPOINT).appendField(new Blockly.FieldDropdown(ke_DrawPixel_NUM), "DrawPixel_TYPE");
        this.setInputsInline(true);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        //this.setTooltip(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOWPOINT_TOOLTIP);
    }
};
//执行器_点阵屏显示_旋转变量
var ke_Rotation_NUM = [
    ["0°", "0"],
    ["-90°", "1"],
    ["+90°", "3"],
    ["180°", "2"]
];

//执行器_点阵屏显示_显示旋转
export const ke_Matrix_Rotation = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName').appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOW);
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_ROTATE).appendField(new Blockly.FieldDropdown(ke_Rotation_NUM), "Rotation_TYPE");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        //   this.setTooltip("");
    }
};
//执行器_点阵屏显示_字符显示
export const ke_matrix_text = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName').appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOW);
        this.appendValueInput("TEXT", String).setCheck([Number, String]).setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.ke_string);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        //this.setTooltip("");
    }
};
//执行器_点阵屏显示_显示图案
export const ke_matrix1 = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName').appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOW).appendField(new Blockly.FieldImage(require("../media/ke_matrix.png"), 70, 32));
        this.appendValueInput("LEDArray").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_PICARRAY);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        //this.setTooltip();
    }
};
//执行器_点阵屏显示_图案数组
export const ke_matrix2 = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_ARRAYVAR).appendField(new Blockly.FieldTextInput("LedArray1"), "VAR");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a81").appendField(new Blockly.FieldCheckbox("FALSE"), "a82").appendField(new Blockly.FieldCheckbox("FALSE"), "a83").appendField(new Blockly.FieldCheckbox("FALSE"), "a84").appendField(new Blockly.FieldCheckbox("FALSE"), "a85").appendField(new Blockly.FieldCheckbox("FALSE"), "a86").appendField(new Blockly.FieldCheckbox("FALSE"), "a87").appendField(new Blockly.FieldCheckbox("FALSE"), "a88");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a71").appendField(new Blockly.FieldCheckbox("FALSE"), "a72").appendField(new Blockly.FieldCheckbox("FALSE"), "a73").appendField(new Blockly.FieldCheckbox("FALSE"), "a74").appendField(new Blockly.FieldCheckbox("FALSE"), "a75").appendField(new Blockly.FieldCheckbox("FALSE"), "a76").appendField(new Blockly.FieldCheckbox("FALSE"), "a77").appendField(new Blockly.FieldCheckbox("FALSE"), "a78");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a61").appendField(new Blockly.FieldCheckbox("FALSE"), "a62").appendField(new Blockly.FieldCheckbox("FALSE"), "a63").appendField(new Blockly.FieldCheckbox("FALSE"), "a64").appendField(new Blockly.FieldCheckbox("FALSE"), "a65").appendField(new Blockly.FieldCheckbox("FALSE"), "a66").appendField(new Blockly.FieldCheckbox("FALSE"), "a67").appendField(new Blockly.FieldCheckbox("FALSE"), "a68");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a51").appendField(new Blockly.FieldCheckbox("FALSE"), "a52").appendField(new Blockly.FieldCheckbox("FALSE"), "a53").appendField(new Blockly.FieldCheckbox("FALSE"), "a54").appendField(new Blockly.FieldCheckbox("FALSE"), "a55").appendField(new Blockly.FieldCheckbox("FALSE"), "a56").appendField(new Blockly.FieldCheckbox("FALSE"), "a57").appendField(new Blockly.FieldCheckbox("FALSE"), "a58");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a41").appendField(new Blockly.FieldCheckbox("FALSE"), "a42").appendField(new Blockly.FieldCheckbox("FALSE"), "a43").appendField(new Blockly.FieldCheckbox("FALSE"), "a44").appendField(new Blockly.FieldCheckbox("FALSE"), "a45").appendField(new Blockly.FieldCheckbox("FALSE"), "a46").appendField(new Blockly.FieldCheckbox("FALSE"), "a47").appendField(new Blockly.FieldCheckbox("FALSE"), "a48");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a31").appendField(new Blockly.FieldCheckbox("FALSE"), "a32").appendField(new Blockly.FieldCheckbox("FALSE"), "a33").appendField(new Blockly.FieldCheckbox("FALSE"), "a34").appendField(new Blockly.FieldCheckbox("FALSE"), "a35").appendField(new Blockly.FieldCheckbox("FALSE"), "a36").appendField(new Blockly.FieldCheckbox("FALSE"), "a37").appendField(new Blockly.FieldCheckbox("FALSE"), "a38");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a21").appendField(new Blockly.FieldCheckbox("FALSE"), "a22").appendField(new Blockly.FieldCheckbox("FALSE"), "a23").appendField(new Blockly.FieldCheckbox("FALSE"), "a24").appendField(new Blockly.FieldCheckbox("FALSE"), "a25").appendField(new Blockly.FieldCheckbox("FALSE"), "a26").appendField(new Blockly.FieldCheckbox("FALSE"), "a27").appendField(new Blockly.FieldCheckbox("FALSE"), "a28");
        this.appendDummyInput("").appendField(new Blockly.FieldCheckbox("FALSE"), "a11").appendField(new Blockly.FieldCheckbox("FALSE"), "a12").appendField(new Blockly.FieldCheckbox("FALSE"), "a13").appendField(new Blockly.FieldCheckbox("FALSE"), "a14").appendField(new Blockly.FieldCheckbox("FALSE"), "a15").appendField(new Blockly.FieldCheckbox("FALSE"), "a16").appendField(new Blockly.FieldCheckbox("FALSE"), "a17").appendField(new Blockly.FieldCheckbox("FALSE"), "a18");
        this.setOutput(true, Number);
        //this.setTooltip();
    }
};


//执行器_点阵屏显示_清除屏幕
export const ke_matrix_clear = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("").appendField(new Blockly.FieldTextInput('myMatrix'), 'matrixName').appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOW);
        this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_CLEAR);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        //this.setTooltip();
    }
};

///////////////////1602LCD无IIC//////////////////////
/*export const ke_1602lcd_w = {
  init: function() {
      this.setColour(DISPLAY_HUE);
      this.appendDummyInput("")
          .appendField("LCD1602")
          .appendField(new Blockly.FieldImage(require("../media/ke_lcd1602.png"), 70, 32));
    this.appendValueInput("TEXT1", String)
        .setCheck([String,Number])
        .setAlign(Blockly.ALIGN_RIGHT)
        //.appendField(new Blockly.FieldTextInput('mylcd'), 'VAR')
        .appendField(Blockly.Msg.MIXLY_LCD_PRINT1);
    this.appendValueInput("TEXT2", String)
        .setCheck([String,Number])
        .setAlign(Blockly.ALIGN_RIGHT)
        .appendField(Blockly.Msg.MIXLY_LCD_PRINT2);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
  }
};
*/


///////////////////1602LCD_init//////////////////////
export const ke_1602lcd_init = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendValueInput("address", Number)
            //.setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_SETUP)
            .appendField(Blockly.Msg.Kids_lcd_p)
            .appendField(new Blockly.FieldDropdown([['1602', '16,2'], ['2004', '20,4']]), 'TYPE')
            .appendField(Blockly.Msg.Kids_shilihua)
            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR')
            .appendField(Blockly.Msg.Kids_iic_pin)
            //.appendField("address:");

            //.setCheck(Number)
            //.setAlign(Blockly.ALIGN_RIGHT)
            //.appendField("address:");
            .appendField(Blockly.Msg.MIXLY_LCD_ADDRESS);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
    }
};


export const ke_1602lcd = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_DF_LCD)
            .appendField(new Blockly.FieldImage(require("../media/ke_lcd1602.png"), 70, 32));
        this.appendValueInput("TEXT", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            // .appendField(Blockly.Msg.MIXLY_DF_LCD)

            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR')
            .appendField(Blockly.Msg.MIXLY_LCD_PRINT1);
        this.appendValueInput("TEXT2", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LCD_PRINT2);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

export const ke_1602lcd_print2 = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendValueInput("row", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_DF_LCD)
            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR')
            .appendField(Blockly.Msg.MIXLY_LCD_ROW);
        this.appendValueInput("column", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LCD_COLUMN);
        this.appendValueInput("TEXT", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LCD_PRINT);
        this.setPreviousStatement(true, null);
        this.setInputsInline(true);
        this.setNextStatement(true, null);
    }
};




///////////////////1602LCD//////////////////////
/*export const ke_1602lcd = {
  init: function() {
    this.setColour(DISPLAY_HUE);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.MIXLY_ke_1602LCD)
    .appendField(new Blockly.FieldImage(require("../media/ke_lcd1602.png"), 70, 32));
    this.appendValueInput("TEXT1", String)
    .setCheck([String,Number])
    .setAlign(Blockly.ALIGN_RIGHT)
    .appendField(Blockly.Msg.MIXLY_ke_print1);
    this.appendValueInput("TEXT2", String)
    .setCheck([String,Number])
    .setAlign(Blockly.ALIGN_RIGHT)
    .appendField(Blockly.Msg.MIXLY_ke_print2)
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
  }
};*/

export const ke_1602lcd_left = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.Kids_lcd_left)
            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR');

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

export const ke_1602lcd_right = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.Kids_lcd_right)
            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR');

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

export const ke_1602lcd_clear = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_DF_LCD)
            .appendField(new Blockly.FieldTextInput('mylcd'), 'VAR')
            .appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LCD_STAT_ON, "display"], [Blockly.Msg.MIXLY_LCD_STAT_OFF, "noDisplay"], [Blockly.Msg.MIXLY_LCD_STAT_CURSOR, "cursor"], [Blockly.Msg.MIXLY_LCD_STAT_NOCURSOR, "noCursor"], [Blockly.Msg.MIXLY_LCD_STAT_BLINK, "blink"], [Blockly.Msg.MIXLY_LCD_STAT_NOBLINK, "noBlink"], [Blockly.Msg.MIXLY_LCD_STAT_CLEAR, "clear"], [Blockly.Msg.MIXLY_LCD_NOBACKLIGHT, "noBacklight"], [Blockly.Msg.MIXLY_LCD_BACKLIGHT, "backlight"]]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

//128X32 LCD display  -- 初始化

export const lcd128_init = {
    init: function () {
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32))
            .appendField(Blockly.Msg.MIXLY_LCD128_SETUP);
        this.setColour(DISPLAY_HUE);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

//128X32 LCD display 显示第几行第几列
export const lcd128_cursor = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_LCD128_CURSOR)
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32));
        this.appendValueInput("row", Number)  //数字输入和上面的图片分开写
            .setCheck(Number)  //少了这个
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LCD_ROW);
        this.appendValueInput("col", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LCD_COLUMN);
        this.setPreviousStatement(true, null);
        this.setInputsInline(true);
        this.setNextStatement(true, null);
    }
};


//128X32 LCD display 显示字符
export const lcd128_string = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_DISPLAY_STRING)
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32));
        this.appendValueInput("string", String)
            .setCheck([Number, String])
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
    }
};


//128X32 LCD display 画点坐标
export const lcd128_pixel = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32))
            .appendField(Blockly.Msg.MIXLY_ke_LCD128_PIXLE);
        this.appendValueInput("row", Number)
            .setCheck()
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput("col", Number)
            .setCheck()
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


//128X32 LCD display 删除点坐标
export const lcd128_d_pixel = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput()
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32))
            .appendField(Blockly.Msg.MIXLY_ke_LCD128_D);
        this.appendValueInput("row", Number)
            .setCheck()
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput("col", Number)
            .setCheck()
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

//128X32 LCD display 清屏
export const lcd128_clear = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_LCD128_CLEAR)
            .appendField(new Blockly.FieldImage(require("../media/12832.png"), 84, 32));
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////LCD1602清屏///////////////////////
/*export const ke_1602lcd_clear = {
  init: function() {
    this.setColour(DISPLAY_HUE);
    this.appendDummyInput("")
    .appendField("1602LCD_clear")
    //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
  }
};*/


/////////////////2004LCD//////////////////////
export const ke_2004lcd = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_2004LCD);
        this.appendValueInput("TEXT1", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print1);
        this.appendValueInput("TEXT2", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print2)
        this.appendValueInput("TEXT3", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print3);
        this.appendValueInput("TEXT4", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print4)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


///////////////////OLED_init///////////////////////
export const ke_OLED_init = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_init)
            .appendField(Blockly.Msg.Kids_iic_pin);
        //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_piexl///////////////////////
export const ke_OLED_piexl = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_piexl);
        this.appendValueInput("val_x", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        //.appendField(new Blockly.FieldImage(require("../media/ke_oled.png"), 70, 32))
        //.appendField(Blockly.Msg.Kids_iic_pin);
        //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_line///////////////////////
export const ke_OLED_line = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_line)
            .appendField(Blockly.Msg.ke_oled_cong);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_dao);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


///////////////////OLED_rect///////////////////////
export const ke_OLED_rect = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_rect);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_kai);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_chang);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_kuan);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_fullrect///////////////////////
export const ke_OLED_fullrect = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_fil_lrect);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_kai);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_chang);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_kuan);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};



///////////////////OLED_roundrect///////////////////////
export const ke_OLED_roundrect = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_r_rect);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_kai);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_chang);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_kuan);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendValueInput("val_round", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_radius);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


///////////////////OLED_fullroundrect///////////////////////
export const ke_OLED_fullroundrect = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_r_fill_rect);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_kai);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_chang);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_kuan);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendValueInput("val_round", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_radius);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};



///////////////////OLED_circle///////////////////////
export const ke_OLED_circle = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_circle);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendValueInput("val_circle", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_circle_radius);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_fullcircle///////////////////////
export const ke_OLED_fullcircle = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_fill_circle);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendValueInput("val_circle", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_circle_radius);

        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_三角形///////////////////////
export const ke_OLED_triangle = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_triangle)
            .appendField(Blockly.Msg.ke_oled_angle1);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_angle2);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_angle3);
        this.appendValueInput("val_x3", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y3", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};



///////////////////OLED_填充三角形///////////////////////
export const ke_OLED_fulltriangle = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_fill_triangle)
            .appendField(Blockly.Msg.ke_oled_angle1);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_angle2);
        this.appendValueInput("val_x2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y2", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);

        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_angle3);
        this.appendValueInput("val_x3", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y3", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED_string///////////////////////
export const ke_OLED_string = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_string1);
        this.appendValueInput("size", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.Kids_size);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_weizhi);
        this.appendValueInput("val_x1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_x);
        this.appendValueInput("val_y1", Number)
            .setCheck(Number);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_y);
        this.appendValueInput("TEXT1", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.ke_oled_print);
        //.appendField(new Blockly.FieldImage(require("../media/ke_oled.png"), 70, 32))
        //.appendField(Blockly.Msg.Kids_iic_pin);
        //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


////////////////////OLED////////////////////////
export const ke_oled = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_OLED);


        this.appendValueInput("size", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.Kids_size);

        this.appendValueInput("TEXT1", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print1);
        this.appendValueInput("TEXT2", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print2);
        this.appendValueInput("TEXT3", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print3);
        this.appendValueInput("TEXT4", String)
            .setCheck([String, Number])
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_ke_print4);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};

///////////////////OLED清屏///////////////////////
export const ke_oled_clear = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.ke_oled_clear)
        //.appendField(new Blockly.FieldDropdown([[Blockly.Msg.Kids_ON, "HIGH"], [Blockly.Msg.Kids_OFF, "LOW"]]), "STAT");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


/////////////////////////////通讯/////////////////////////////////////////////

////////////////红外接收////////////////////////////
//红外接收模块
export const ke_ir_r = {
    init: function () {
        this.setColour(COMMUNICATE_HUE);
        this.appendValueInput("PIN", Number)
            .appendField(new Blockly.FieldTextInput('ir_rec'), 'VAR')
            .appendField(Blockly.Msg.MIXLY_ke_IR_R)
            .appendField(new Blockly.FieldImage(require("../media/ke_irr.png"), 70, 32))
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendStatementInput('DO')
            .appendField(Blockly.Msg.MIXLY_ke_read);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
        this.setTooltip(Blockly.Msg.MIXLY_IR_RECIEVE_TOOLTIP);
    },
    getVars: function () {
        return [this.getFieldValue('VAR')];
    },
    renameVar: function (oldName, newName) {
        if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
            this.setTitleValue(newName, 'VAR');
        }
    }
};

////////////////////红外发射/////////////////////
export const ke_ir_s = {
    init: function () {
        this.setColour(COMMUNICATE_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_ke_IR_E)
            .appendField(new Blockly.FieldImage(require("../media/ke_irs.png"), 43, 32));

        this.appendValueInput("num1", Number)
            .setCheck(Number)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("Send");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};


//////////////////////RFID////////////////////////////
export const rc522_i2c_init = {
    init: function () {
        this.setColour(COMMUNICATE_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_rc522_iic_init)
            .appendField(new Blockly.FieldImage(require("../media/rc522_iic.png"), 60, 40));
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
    }
};

export const rc522_i2c_read = {
    init: function () {
        this.setColour(COMMUNICATE_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_rc522_iic_read)
            .appendField(new Blockly.FieldImage(require("../media/rc522_iic.png"), 60, 40));
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip('');
    }
};

//////////////////////蓝牙////////////////////////////
export const ke_bluetooth = {
    init: function () {
        this.setColour(COMMUNICATE_HUE);
        this.appendValueInput("PIN1", Number)
            .appendField(new Blockly.FieldTextInput('val'), 'VAL')
            .appendField(Blockly.Msg.MIXLY_ke_BLUETOOTH)
            .appendField(new Blockly.FieldImage(require("../media/ke_bluetooth.png"), 70, 32))
            .appendField("RX:")
            .setCheck(Number);
        this.appendValueInput("PIN2", Number)
            .appendField("TX:")
            .setCheck(Number);
        this.appendStatementInput('DO')
            .appendField(Blockly.Msg.MIXLY_ke_read);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setInputsInline(true);
        this.setTooltip("bluetooth");
    },
    getVars: function () {
        return [this.getFieldValue('VAL')];
    },
    renameVar: function (oldName, newName) {
        if (Blockly.Names.equals(oldName, this.getFieldValue('VAL'))) {
            this.setTitleValue(newName, 'VAL');
        }
    }
};